﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AugustVisual
{
    public class UserInfo : INotifyPropertyChanged
    {
        public UserInfo()
        {
            AllUserInfos.Add(this);

            
            //AllUserInfos.Insert(0, this);
        }
        public UserInfo(string name, int age, string address, string phone, bool append = true)
        {
            this.Name = name;
            this.Age = age;
            this.Address = address;
            this.Phone = phone;
            if (append)
                AllUserInfos.Add(this);
        }


        public static ObservableCollection<UserInfo> AllUserInfos { get; set; } = new ObservableCollection<UserInfo>();

        private int age;
        public int Age
        {
            get { return age; }
            set { age = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Age")); }
        }

        private string phone;
        public string Phone
        {
            get { return phone; }
            set { phone = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Phone")); }
        }

        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name")); }
        }

        private string address;
        public string Address
        {
            get { return address; }
            set { address = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Address")); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
